package com.newcoder.community.util;

import org.omg.IOP.ENCODING_CDR_ENCAPS;

import javax.naming.ldap.PagedResultsControl;

public class RedisKeyUtil {
    private static final String SPLIT=":";
    private static final String PREFIX_ENTITY_LIKE="like:entity";
    private static String PREFIX_USER_LIKE="like:user";
    private static String PREFIX_FOLLOWEE="followee";
    private static String PREFIX_FOLLOWER="follower";
    private static String PREFIX_KAPTCHA="kaptcha";
    private static String PREFIX_TICKET="ticket";
    private static String PREFIX_USER="user";
    private static String PREFIX_UV= "uv";
    private static String PREFIX_DAU= "dau";
    private static String PREFIX_POST="post";

    //生成某个实体的赞
    public static String getEntityLikeKey(int entityType,int entityId){
        return PREFIX_ENTITY_LIKE+SPLIT+entityType+SPLIT+entityId;
    }
    //生成某一用户的赞
     public static String getUserLikeKey(int userId){
        return PREFIX_USER_LIKE+SPLIT+userId;
     }
     //某个用户关注的实体
    //followee:userId:entityType->zset(entityId,now)
    public static String getFolloweeKey(int userId,int entityType){
        return PREFIX_FOLLOWEE+SPLIT+userId+SPLIT+entityType;
    }
    //某个实体的粉丝
    //follower:entityType:entityId->zset(userId,now)
    public static String getFollowerKey(int entityType,int entityId){
        return PREFIX_FOLLOWER+SPLIT+entityType+SPLIT+entityId;
    }
    // 登录验证码
    public static String getKatchaKey(String owner){
          return PREFIX_KAPTCHA+SPLIT+owner;
    }
    //登录的凭证
    public static String getTicketKey(String ticket){
        return PREFIX_TICKET+SPLIT+ticket;
    }
    //用户
    public static String getUserKey(int userId){
         return PREFIX_USER+SPLIT+userId;
    }
    //单日uv
    public static String getUVKey(String data){
        return PREFIX_UV+SPLIT+data;
    }
    //区间uv
    public static String getUVKey(String startData,String endData){
        return PREFIX_UV+SPLIT+startData+SPLIT+endData;
    }
    //单日dau
    public static String getDAUKey(String data){
        return PREFIX_DAU+SPLIT+data;
    }
    //区间dau
    public static String getDAUKey(String startData,String endData){
        return PREFIX_DAU+SPLIT+startData+SPLIT+endData;
    }
    // 返回统计帖子分数
    public static String getPostScoreKey(){
        return PREFIX_POST+SPLIT+"score";
    }
}
